<template lang="pug">
  v-form(direction="vertical" style="width:400px")
    v-form-item(label="管理员昵称")
      v-input(type="text" placeholder="管理员昵称" size="large" v-model="formData.display_name")
    v-form-item(label="管理员名称" required)
      v-input(type="text" placeholder="管理员名称" size="large" v-model="formData.username")
    v-form-item(label="管理员密码" required)
      v-input(type="text" placeholder="管理员密码" size="large" v-model="formData.password")
    v-form-item(label="管理员邮箱" required)
      v-input(type="text" placeholder="管理员邮箱" size="large" v-model="formData.email")
    v-form-item(style="margin-top:24px")
      v-button( type="primary" html-type="button" @click="submitForm") 确定
</template>
<script>
export default {
  name: 'permissions-create',
  data () {
    return {
      rolelist: [{value: '1', label: '区域1'}, {value: '2', label: '区域2'}],
      formData: {
        display_name: '',
        username: '',
        password: '',
        email: ''
      }
    }
  },
  mounted () {
  },
  methods: {
    submitForm () {
      this.$http.post('rbac/admin', this.formData)
        .then(res => {
          let result = res.data
          if (result.ret === 0) {
            this.$message.info(result.msg)
            this.formData = {
              display_name: '',
              username: '',
              password: '',
              email: ''
            }
          }
        })
        .catch(err => {
          console.log(err)
        })
    }
  }
}
</script>
